package sonic.game.tile;
import java.awt.Graphics;

import sonic.game.Game;
import sonic.game.animation.Animation;

/**
 * Game Effect
 * 
 * Handles special effects
 * @author RGreenlees
 */

public class GameEffect extends Tile {

	protected Animation effectAnim;
	
	public GameEffect(float xPos, float yPos, Animation effect)
	{
		effectAnim = new Animation(effect.currentAnimTime, effect.bLooping, effect.frames);
		location.x = xPos;
		location.y = yPos;
		collisionType = eCollisionType.CT_NONE;
		bAlwaysRelevant = true;
	}
	
	/** Effects live as long as their animation does. If an effect has a looping animation it will live forever unless destroyed elsewhere */
	public void update(double deltaTime)
	{
		super.update(deltaTime);
		effectAnim.update(deltaTime);
		if (effectAnim.bFinished)
		{
			destroy();
		}
	}
	
	
	public void updateBounds()
	{

	}
	
	public void paint(Graphics g)
	{
		g.drawImage(effectAnim.getCurrentFrame(), (int) location.x + (320-(int) Game.camera.location.x), (int) location.y + (240-(int) Game.camera.location.y), null);
	}
}
